package com.scitc.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author: zk
 * @date: 2021/5/3 7:10
 * @description: 结果集类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private int code; // 200正常， 400异常
    private String msg;
    private Object data;

    public static Result  success(Object data) {
        return success(200, "success", data);
    }

    public static Result  success(String msg, Object data) {
        return success(200, msg, data);
    }

    public static Result success(int code, String msg, Object data) {
        return new Result(code, msg, data);
    }

    public static Result fail(String msg) {
        return fail(400, msg, null);
    }

    public static Result fail(String msg, Object data) {
        return fail(400, msg, data);
    }

    public static Result fail(int code, String msg, Object data) {
        return new Result(code, msg, data);
    }
}
